<!--银行票据签发修改页面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :labelWidth="80"
    ></ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('明细', scope.row);
                  },
                },
                {
                  label: '修改',
                  visible: scope.row.status == '02',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('修改', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <edit-info-dialog ref="editInfoDialog" :dictMap="dictMap" @editComplete="editComplete"></edit-info-dialog>
    <!-- 明细弹出框 -->
    <details-dialog
      ref="detailsDialog"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></details-dialog>
  </div>
</template>
<script>
import { apiUrlConfig, detailsQuery } from "@/api/cnaps/bepsDraft/bank_note_issuance_update.js";
import DetailsDialog from "./components/BankNoteIssuanceUpdateDetails";
import { listPageMixin } from "@/libs/listPageMixin";
import EditInfoDialog from "./components/BankNoteIssuanceEntryDialog";

export default {
  name: "BankNoteIssuanceUpdate",
  mixins: [listPageMixin],
  components: {
    DetailsDialog,
    EditInfoDialog,
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: ["TXN_SOURCE", "BIZ_TYPE", "CBFLAG", "BANK_BIZ_TYPE","DRAFT_CODE","CPG_STATUS"],
      //  明细弹框数据
      // form表单字段
      formData: {
        issuedBrno: "",
        issuedBrname: "",
        issuedDate: "",
        draftType: "",
        draftCode: "",
        issuedActno: "",
        issuedName: "",
        payeeName: "",
        issuedAmount: "",
        promptDate: "",
        remarks: "",
        agentBrno: "",
        agentBrname: "",
      },
      showSearch: true,
      // 查询参数
      queryParams: {
        idSeqNo: "",
        idDate: "",
      },
      formOptions: [],
      opButtonList: () => {
        return [
          {
            label: "新增交易",
            type: "primary",
            icon: "",
            // permission: "user:xxx:xxx",
            clickFun: () => {
              this.handleAction("transAdd");
            },
          },
        ];
      },
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "200", align: "center" },
        {
          label: `出票日期`,
          prop: "issuedDate",
          width: "150",
          align: "center",
          type: "date",
        },
        {
          label: `票据类型`,
          prop: "draftType",
          width: "150",
          align: "center",
          type: "date",
          dictCode: "DRAFT_TYPE",
        },
        {
          label: `申请人名称`,
          prop: "issuedName",
          width: "150",
          align: "center",
        },
        {
          label: `收款人名称`,
          prop: "payeeName",
          width: "150",
          align: "center",
        },
        {
          label: `出票金额`,
          prop: "issuedAmount",
          width: "140",
          align: "center",
          type: "price",
        },
        {
          label: `业务状态`,
          prop: "status",
          width: "140",
          align: "center",
          dictCode: "CPG_STATUS",
        },
        {
          label: `录入操作员`,
          prop: "mdTlrno",
          width: "140",
          align: "center",
        },
        {
          label: `录入时间`,
          prop: "mdTime",
          width: "200",
          align: "center",
          type: "date",
        },
      ],
    };
  },
  mounted() {
    this.formOptions = [
      {
        type: "singleDate",
        prop: "idDate",
        defaultAttr: {
          label: "出票日期",
          placeholder: "请输入出票日期",
        },
      },
      {
        type: "input",
        prop: "idSeqNo",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
    ];
  },
  methods: {
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },

    handleAction(type, row = {}) {
      if ("明细" === type || "修改" === type) {
        // 明细信息
        detailsQuery(row).then((res) => {
          this.formData = _.clone(res.result);
          this.$refs.detailsDialog.show(type);
        });
      } else if ("transAdd" === type) {
        this.$refs.editInfoDialog.show();
      }
    },
  },
};
</script>
